<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>

#ads{width:120px;height:100px;position:fixed;bottom:-100px;right:0px;background:#f90;}
#top{background:#f90;}


	</style>
</head>
<body>
	<input type="text" value="请输入内容">
	<div id="ads">我是一个小广告</div>
	<div><img src="moren.gif" alt=""></div>
	<div><img src="moren.gif" alt=""></div>
	<div><img src="moren.gif" alt=""></div>
	<div><img src="moren.gif" alt=""></div>
	<div><img src="moren.gif" alt=""></div>
	<div><img src="moren.gif" alt=""></div>
	<div><img src="moren.gif" alt=""></div>
	<div><img src="moren.gif" alt=""></div>
	<section id="top"><img src="moren.gif" alt=""></section>
	<hr />
	<div><img src="moren.gif" alt=""></div>
	<div><img src="moren.gif" alt=""></div>
	<div><img src="moren.gif" alt=""></div>
	<div><img src="moren.gif" alt=""></div>
	<div><img src="moren.gif" alt=""></div>
	<div><img src="moren.gif" alt=""></div>
	<div><img src="moren.gif" alt=""></div>
	<div><img src="moren.gif" alt=""></div>
	<div><img src="moren.gif" alt=""></div>
	<div><img src="moren.gif" alt=""></div>
</body>
<script type="text/javascript">
	
var oInput = document.getElementsByTagName('input')[0];

oInput.onfocus = function () {
	if (oInput.value == '请输入内容') {
		oInput.value = '';
	}
}

oInput.onblur = function () {
	if (oInput.value == '') {
		oInput.value = '请输入内容';
	}
}

var oAds = document.getElementById('ads');
var bottom = parseInt(getStyle(oAds,'bottom'));
var timeId = setInterval(function(){
										bottom += 10;
										oAds.style.bottom = bottom+'px';
										if(bottom == 0) {
											clearInterval(timeId);
										}
								},100);

oAds.onclick = function() {
	this.parentNode.removeChild(this);
}




function getStyle(obj,attr) {
	if (typeof(obj.currentStyle) == 'undefined') {
		return getComputedStyle(obj)[attr];
	}
	return obj.currentStyle[attr];
}


var oTop = document.getElementById('top');
var offsetTop = oTop.offsetTop;
window.onscroll = function() {
	if(document.body.scrollTop >= offsetTop) {
		oTop.style.position = 'fixed';
		oTop.style.top = '0px';
	} else {
		oTop.style.position = '';
	}
}





</script>
</html>